//
//  ViewController.m
//  aaaaaaaa
//
//  Created by paycloud110 on 15/12/10.
//  Copyright © 2015年 paycloud110. All rights reserved.
//

#import "ViewController.h"
#import "JWAlarm.h"
#import "JWSQLDateSave.h"
#import "dataModel.h"


@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIButton *add;
@property (weak, nonatomic) IBOutlet UIButton *delete;
@property (weak, nonatomic) IBOutlet UIButton *update;
@property (weak, nonatomic) IBOutlet UIButton *kan;
@property (weak, nonatomic) IBOutlet UIButton *deleteChartData;
@property (weak, nonatomic) IBOutlet UIButton *deleteChart;
@property (weak, nonatomic) IBOutlet UIButton *displayData;

/**  */
@property (nonatomic, strong) JWAlarm *alarm;
/**  */
@property (nonatomic, strong) dataModel *model;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [[JWSQLDateSave shareSQLDateSave] createDataBase];
}
static NSString *property = @"model";

/** 插入一条数据 */
- (IBAction)add:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] insertOneLineDataProperty:property withPropertyValue:self.model];
}
/** 查看一条数据 */
- (IBAction)kan:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] readOneLineDataNeedProperty:property completedBlock:^(id propertyValue) {
        NSLog(@"%@", propertyValue);
    }];
}
/** 更新一条数据 */
- (IBAction)update:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] updateOneLineDataProperty:@"hhh" withPropertyValue:@"9865432"];
}
/** 删除一条数据 */
- (IBAction)delete:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] cancelOneLineDataProperty:@"ww"];
}
/** 删除表中所有数据 */
- (IBAction)deleteChartData:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] cancelDataBaseAllData];
}
/** 删除表 */
- (IBAction)deleteChart:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] cancelDataBase];
}
/** 打印内容 */
- (IBAction)displayData:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] readDataBaseAllChartData:^(id idObject) {
        NSLog(@"%@", idObject);
    }];
}
/** 创建数据库 */
- (IBAction)foundChart:(id)sender
{
    [[JWSQLDateSave shareSQLDateSave] createDataBase];
}
- (IBAction)openDataBase:(id)sender {
    [[JWSQLDateSave shareSQLDateSave] openDataBase];
}
- (IBAction)closeDataBase:(id)sender {
    [[JWSQLDateSave shareSQLDateSave] closeDataBase];
}
- (JWAlarm *)alarm
{
    if (_alarm == nil) {
        _alarm = [[JWAlarm alloc] init];
        _alarm.getupCycle = @"333";
    }
    return _alarm;
}
- (dataModel *)model
{
    if (_model == nil) {
        _model = [[dataModel alloc] init];
        _model.getupShake = @"摇来摇去";
        _model.whetherOpen = true;
    }
    return _model;
}
@end
